package cn.edu.zafu.bigdata.x.zzzznnn.c;

public class Cube {
    private double length;
    private double width;
    private double height;
    //构造方法
    public Cube(double length,double width,double height){
        this.length=length;
        this.width=width;
        this.height=height;
    }
    //获取方法
    public double getLength(){
        return length;
    }
    public double getWidth(){
        return width;
    }
    public double getHeight(){
        return height;
    }
    //重写equals方法
    @Override
    public boolean equals(Object obj){
        if(this==obj){
            return true;
        }
        if(obj==null||getClass()!=obj.getClass()){
            return false;
        }
        Cube other=(Cube) obj;
        return Double.compare(length,other.length)==0 &&
                Double.compare(width,other.width)==0 &&
                Double.compare(height,other.height)==0;
    }
    public static void main(String[] args) {
        Cube cube1 = new Cube(5.0, 5.0, 5.0);
        Cube cube2 = new Cube(5.0, 5.0, 5.0);
        Cube cube3 = new Cube(3.0, 3.0, 3.0);
        System.out.println("cube1和cube2是否相等:" + cube1.equals(cube2));
        System.out.println("cube1和cube3是否相等:" + cube1.equals(cube3));
    }}
